using Neighbors.Database;
using PRTelegramBot.Attributes;
using PRTelegramBot.Extensions;
using PRTelegramBot.InlineButtons;
using PRTelegramBot.Interface;
using PRTelegramBot.Models;
using PRTelegramBot.Models.InlineButtons;
using PRTelegramBot.Utils;
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.ReplyMarkups;

namespace Neighbors.Commands;

public class GetMyInformation
{
    [ReplyMenuHandler("Мои данные")]
    [SlashHandler("/my_info")]
    public static async Task ReplyMyInformation(ITelegramBotClient botClient, Update update)
    {
        FlatRepository flatRepository = new FlatRepository();

        var myFlat = await flatRepository.GetNeighborsByChatIdAsync(update.Message.Chat.Id);
        if (myFlat == null)
            await PRTelegramBot.Helpers.Message.Send(botClient, update, "Ваших данных нет в базе.");

        var message = myFlat!.GetStringInfoAbout();

        var option = new OptionMessage();
        var menu = new List<KeyboardButton>
        {
            new KeyboardButton("Редактировать"),
            new KeyboardButton("Удалить"),
        };

        var mainMenu = MenuGenerator.ReplyKeyboard(2, menu);
        option.MenuReplyKeyboardMarkup = mainMenu;

        await PRTelegramBot.Helpers.Message.Send(botClient, update, message, option);
    }
}
